﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>登录</title>
    <script src="/lib/jquery/jquery.min.js" charset="utf-8"></script>
    <script src="~/js/cookie.js"></script>
    <script src="~/js/myhttp.js"></script>
    <link rel="stylesheet" type="text/css" href="~/css/login.css" />
    <link rel="stylesheet" type="text/css" href="/css/backgroundColor.css" />
</head>
<body>
    <div class="login_bg_out background_all_color">
        <div class="system-name">
            短纤维率快速检测系统
        </div>
        <div class="login_inner">
            <div class="login_bg">
                <img src="~/images/login_bg.png" />
            </div>
            <div class="login_all">
                <div class="login_all_title">登录</div>
                <p class="en">User Login</p>
                <form method="post" id="cxForm" autocomplete="off">
                    <ul class="login_all_ul">
                        <li>
                            <input class="sryhm"
                                   type="text"
                                   id="username"
                                   name="username"
                                   placeholder="请输入账号"
                                   autocomplete="off"
                                   value="" />
                        </li>

                        <li>
                            <input class="srmm"
                                   type="password"
                                   id="password"
                                   name="password"
                                   placeholder="请输入密码"
                                   value=""
                                   autocomplete="new-password" />
                        </li>
                    </ul>
                </form>
                <span id="cxLoginBut">
                    <a class="login_btn" id="btn_login">登录</a>
                </span>
                <a class="zczh_bnt register-btn" href="/Register">立即注册</a>
            </div>

        </div>
        @* <div class="login_bottom"> *@
        @*     <p> *@
        @*         北京智棉科技有限公司 版权所有 *@
        @*     </p> *@
        @* </div> *@
    </div>


    <script src="~/js/verifyRules.js" type="text/javascript"></script>
    <script src="~/js/jsencrypt.min.js"></script>
    <input id="pxkey" type="button" hidden="hidden" value="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCLqzqTeRC4uoRx2R61hda7Y82R
    TKH2bWlgWigXaz3t337p3z47jJ4c/klQOIY5XTcxf1n+nzyd5QdJLy7KX76Izg0M
    MRNg8TIzjFyQqbh6P2Hx6zqh0N9SSIF9HvUcJ7XuzMQc1E1te0d9gLOG7pO58l3a
    r8UYG0t3uLnqlC64mwIDAQAB" />

    <script>
        $(window).resize(function () {
            remresize()
        });

        function remresize() // 绑定到窗口的这个事件中
        {
            whdef = 100 / 1920;
            wH = window.innerHeight; // 当前窗口的高度
            wW = window.innerWidth; // 当前窗口的宽度
            rem = wW * whdef; // 以默认比例值乘以当前窗口宽度,得到该宽度下的相应FONT-SIZE值
            $('html').css('font-size', rem + "px");
        }
        remresize()
        $(".xxj,.jdgl").hide()
        $(".navlist a:nth-child(6)").mouseenter(function () {
            $(".xxj").show()
        })
        $(".navlist a:nth-child(6)").mouseleave(function () {
            $(".xxj").hide()
        })
        $(".navlist a:nth-child(7)").mouseenter(function () {
            $(".jdgl").show()
        })
        $(".navlist a:nth-child(7)").mouseleave(function () {
            $(".jdgl").hide()
        })
        $(".navlist").on("click", "ul li", function () {
            $(".navlist ul").hide()
        })
        // table
        var thlength = $(".contablescrol .table tr th").length - 2;
        $(".contablescrol .table").css({
            'width': 5 * rem * thlength
        })
        $(".contablescrol").scroll(function (event) {
            if ($(".contablescrol").scrollLeft() > 0) {
                $(".lefttablediv").show()
            }
        });

        $(document).ready(function () {

            $("#btn_login").click(function () {

                var username = $("#username").val();
                if (!username) {
                    alert("用户名不能为空"); return;
                }


                var password = $("#password").val();
                if (!password) {
                    alert("密码不能为空"); return;
                }

                var password_reg = /^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*)(?=.*[`~!@Html.Raw("@")#$%^&*()_\-+=<>.?:"{}].*).{8,64}$/;
                // 正则验证密码  包含大小写字母和数字 并且      长度8-128
                if (!password_reg.test(password)) {
                    alert("密码格式错误");
                    return;
                }

                if (_isKeyBoardContinuousChar(password)) {
                    alert("键盘上连续字符不能超过3位");
                    return;
                }
                if (_isContinuousChar(password)) {
                    alert("输入连续字母不能有3位");
                    return;
                }
                if (_isContinuousOrRepeatNum(password)) {
                    alert("连续或重复数字不能有3位");
                    return;
                }

                $('#btn_login').addClass("layui-btn-disabled").attr("disabled", true);//禁用按钮状态
                var encrypt = new JSEncrypt();
                encrypt.setPublicKey($("#pxkey").val());

                username = encrypt.encrypt(username);
                password = encrypt.encrypt(password);

                var login = ajaxPost("/SysPerson/UserLogin", { LoginName: username, PassWord: password });
                if (login != null) {
                    if (login.StatusCode == "200") {
                        var token = login.Data.Token;
                        setCookie('Token', token, 1);
                        window.location.href = "/Home";
                        //不需要打开Iframe页面
                        // var url = 'http:localhost:48900' + '/SysPerson/Index';
                        // var len = token.length / 200;
                        // for (let i = 0; i < len; i++) {
                        //     let subStr = token.substr(0, 200);
                        //     if (i == 0) {
                        //         url += ('?id=' + subStr);
                        //     } else {
                        //         url += ('&id' + i + '=' + subStr);
                        //     }
                        //     token = token.replace(subStr, "");
                        // }
                        // var iframe = document.createElement('iframe');
                        // iframe.id = 'frame';
                        // iframe.name = 'frame';
                        // iframe.src = url;
                        // iframe.height = 0;
                        // document.body.insertBefore(iframe, document.body.firstChild);
                        
                    }
                    else {
                        alert("操作失败！" + login.Errors);
                    }
                } else {
                    //btn_login
                    $('#btn_login').addClass("layui-btn").attr("disabled", false);//取消禁用按钮状态
                }
            });

        });


    </script>
</body>
</html>